//
//  ContentWindow.m
//  PostalTracker
//
//  Created by Aleksandr Batsuev on 1/31/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ContentWindow.h"


@implementation ContentWindow

- (ContentWindow *)initWithView:(NSView *)view attachedToPoint:(NSPoint)point
{
	// Create dummy initial contentRect for window.
    NSRect contentRect = NSZeroRect;
    contentRect.size = [view frame].size;
    
    if ((self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])) {
		
        [self setMovableByWindowBackground:NO];
		[self setExcludedFromWindowsMenu:YES];
        [self setAlphaValue:1.0];
        [self setOpaque:NO];
        [self setHasShadow:YES];
        [self useOptimizedDrawing:YES];
		[self setLevel:NSPopUpMenuWindowLevel];
        
        [[self contentView] addSubview:view];
		
		[self setFrameOrigin:NSMakePoint(point.x - 15, point.y-contentRect.size.height)];
		
		[super setBackgroundColor:[NSColor whiteColor]];
		if ([self isVisible]) {
			[self display];
			[self invalidateShadow];
		}
		
	}
	
	return self;
}

- (BOOL)canBecomeMainWindow
{
    return NO;
}


- (BOOL)canBecomeKeyWindow
{
    return YES;
}


- (BOOL)isExcludedFromWindowsMenu
{
    return YES;
}

@end
